package com.ssm.controller;


import com.ssm.pojo.Student;
import com.ssm.pojo.Classes;
import com.ssm.service.ClassesService;
import com.ssm.service.StudentService;
import com.ssm.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
public class StudentController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private ClassesService classesService;

    @ResponseBody
    @RequestMapping(value = "/queryStudent", method = RequestMethod.GET)
    public R queryStudent(Student student) throws Exception{
        Map  studentList=studentService.query(student);
        return R.ok().put("data",studentList);
    }
    @ResponseBody
    @RequestMapping(value = "/addStudent", method = RequestMethod.GET)
    public R addStudent(Student student) throws Exception{
        Map  addClass=studentService.addClass(student);
        return R.ok().put("data",addClass);
    }
    @ResponseBody
    @RequestMapping(value = "/addClass", method = RequestMethod.GET)
    public R addClass(Classes clasess) throws Exception{
        Map  addClass=classesService.insert(clasess);
        return R.ok().put("data",addClass);
    }
    @ResponseBody
    @RequestMapping(value = "/queryClass", method = RequestMethod.GET)
    public R queryClass(Classes clasess) throws Exception{
        Map  addClass=classesService.query(clasess);
        return R.ok().put("data",addClass);
    }

}
